package malus.shaofeng.com.beiwomusic.fragment;


import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;

import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;

import malus.shaofeng.com.beiwomusic.R;


public class SpaceMineWorksFragment extends Fragment {
    WebView webView;
    Dialog dialog;

    public SpaceMineWorksFragment() {
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View inflate = inflater.inflate(R.layout.fragment_space_mine_works, container, false);
        //进度条
        dialog = new Dialog(getActivity());
        dialog.setContentView(R.layout.item_running);
        dialog.getWindow().setBackgroundDrawableResource(R.drawable.transaction);
        dialog.setCancelable(false);
        dialog.show();
        webView=(WebView)inflate.findViewById(R.id.space_works_webview);
        HttpUtils httpUtils=new HttpUtils();
        String url = "http://kxai.cn/qms/more_submission_short.html?d=743854";
        httpUtils.send(HttpRequest.HttpMethod.GET,url,
                new RequestCallBack<Object>() {
                    @Override
                    public void onSuccess(ResponseInfo<Object> objectResponseInfo) {
                        dialog.cancel();
                        String result = objectResponseInfo.result.toString();
                        webView.loadDataWithBaseURL("http://kxai.cn/qms/",result,"text/html","utf-8",null);
                    }

                    @Override
                    public void onFailure(HttpException e, String s) {

                    }
                });
        return inflate;
    }


}
